{include file="public/header"/}
{include file="public/left"/}
      
    <div class="content">
        <div class="crumbs clr"><a href="{:url('admin/menu/edit')}"><span class="fr redBtn">新 建</span></a>系统管理 <span class="red">> 菜单管理</span></div>
        <div class="whiteBox">
          <div class="clr pt20 pr20 pb20 pl30">
            <div class="search fr">
              <form action="" method="get" id="searchform">
                搜索：
                <input type="text" id="keywords" value="{$keywords}" name="keywords" placeholder="请输入关键字">
                <span id="search"></span>
              </form>
            </div>
          </div>

          <table class="userTab">
            <tr>
              <th width="5%"></th>
              <th width="5%">序号</th>
              <th width="15%">菜单名称</th>
              <th width="14%">菜单代码</th>
              <th width="8%">功能</th>
              <th width="15%">描述</th>
              <th width="35%">操作</th>
            </tr>
            {volist name="list" id='item' key="key"}
              <tr data-id='{$item.id}'>
              <td><input type="checkbox" name="checkmenu[]" value="{$item.id}"></td>
                <td>{$key}</td>
                <td>{$item.html}{$item.menu_name}</td>
                <td>{$item.menu_tag}</td>
                <td><span class="red"></span></td>
                <td>{$item.menu_remark}</td>
              <td>
                <span menuid="{$item.id}"  title="查看" class="look"></span>
                <span menuid="{$item.id}"  title="编辑" class="edit"></span>
                <span menuid="{$item.id}"  title="添加功能" class="addFuc" ></span>
                <span menuid="{$item.id}"  title="删除" class="del"></span>
              </td>
            </tr>
            {/volist}
          </table>
          <div class="pt40 pr20 pb40 pl40 clr">
            <span class="orangeBtn moreDel">删 除</span>
            <ul class="page fr">
              {$page}
            </ul>
          </div>
        </div>
        
    </div>
    {include file="public/footer"/}
<script type="text/javascript">
    $("#search").click(function(){
        var keywords = $("#keywords").val();
        $("#searchform").submit();
    });

    $(".edit").click(function(){
        var menuid=$(this).attr("menuid");
        var url = "{:url('admin/menu/edit')}?id="+menuid;
        location.href = url;
    });

    $(".look").click(function(){
        var menuid=$(this).attr("menuid");
        var url = "{:url('admin/menu/details')}?id="+menuid;
        location.href = url;
    });

    $('.addFuc').on('click',function(){
        var menuid=$(this).attr("menuid");
        var url = "{:url('admin/menu/fun')}?menuid="+menuid;
        location.href = url;
    });

    $('.del').on('click',function(){
        var id = $(this).parents('tr').attr('data-id');
        layer.confirm('您确定要删除？', {
            btn: ['确认','取消'] //按钮
        }, function(index){
            del(id);
        }, function(){
        });
    });

    $('.moreDel').on('click',function(){
        $('.alert').hide();
        var menuids="";
        $("input[name='checkmenu[]']:checkbox:checked").each(function(){
            menuids+=$(this).val()+',';
        })
        if(!menuids){
            layer.alert("请选择需要删除的记录");
            return false;
        }
        layer.confirm('您确定要删除？', {
            btn: ['确认','取消'] //按钮
        }, function(index){
            delMore(menuids);
        }, function(){
        });
    });

    function del(id){
        $.ajax({
            url : "{:url('admin/menu/delAjax')}",
            type: "post",
            async: true,
            dataType:'json',
            data: {'id':id},
            success: function(data) {
                if(data.code==1){
                    layer.alert(data.msg, function(index){
                        location.reload();
                    });
                }else{
                    layer.alert(data.msg);
                }
            }
        });
    }

    function delMore(ids){
        $.ajax({
            url: "{:url('admin/menu/delMoreAjax')}",
            data:{
                ids : ids,
            },
            type:'post',
            cache:false,
            dataType:'json',
            success:function(data) {
                if(data.code==1)
                {
                    layer.alert(data.msg, function(index){
                        location.reload();
                    });
                }else{
                    layer.alert(data.msg);
                }
            }
        });
    }
</script>
</body>
</html>
    